import React from "react";
import {
  HashRouter as Router,
  Switch,
  Route,
  Redirect,
} from "react-router-dom";
import { mainRoutes } from "./routes";
import "./css/index.css";
import App from "./App";
import ReactDOM from 'react-dom'

ReactDOM.render(
  <Router>
    <Switch>
      {/* <Route path="/login" component={Login} />
          <Route path="/admin/products/list" component={List} />
          return <Route key={route.path} path={route.path} component={route.component}>直接写成
          {...route}里面内容会直接被解构出 
          */}
      <Route path="/admin" render={(routeProps) => <App {...routeProps} />} />
      {mainRoutes.map((route) => {
        return <Route key={route.path} {...route} />;
      })}
      {/* Redirect代表找不到路径的时候全部定向到404 */}
      <Redirect to="/admin" from='/'/>
      <Redirect to="/404"></Redirect>
    </Switch>
  </Router>,
  document.getElementById("root")
);

// axios安装
// cnpm install axios --save

// ant安装
// cnpm install antd --save
